#include <iostream>
#include <stdio.h>

/*
 * 绑定
 */

class Base
{
	public:
		int x;
		int y;
	public:
		Base() {
			x = 1;
			y = 2;
		}

		virtual void print() {
			printf("Base:0x%x 0x%x\n", x, y);
		}
};

class Sub1 : public Base
{
	public:
		int a;
	public:
		Sub1() {
			x = 4;
			y = 5;
			a = 6;
		}

		virtual void print() {
			printf("Sub1:0x%x 0x%x 0x%x\n", x, y, a);
		}
};

class Sub2 : public Base
{
	public:
		int b;
	public:
		Sub2() {
			x = 7;
			y = 8;
			b = 9;
		}

		virtual void print() {
			printf("Sub2:0x%x 0x%x 0x%x\n", x, y, b);
		}
};

void TestBound()
{
	Base b;
	Sub1 s1;
	Sub2 s2;

	Base * arr[] = {&b, &s1, &s2};

	for (int i = 0; i < 3; i++) {
		arr[i]->print();
	}
}

int main(int argc, char ** argv)
{
	TestBound();
	
	return 0;
}

/*
	Base:0x1 0x2
	Sub1:0x4 0x5 0x6
	Sub2:0x7 0x8 0x9
 */

#if 0


#endif
